Automatic reference counting

ABSTRACT

Methods for enabling automatic reference counting are disclosed. A source code is searched for a particular pattern via a compiler associated with a computer system, wherein the source code is written in an existing language and wherein the particular pattern is for a reference associating an object with a portion of memory. The particular pattern is recognized at the computer system. The particular pattern is replaced with an automatic reference counting implementation at the computer system. The source code is executed with the automatic reference counting implementation.

RELATED APPLICATIONS

This application claims priority to the provisional patent application,Ser. No. 61/814,763, entitled “AUTOMATIC REFERENCE COUNTING,” withfiling date Apr. 22, 2013, which is herein incorporated by reference inits entirety.

FIELD OF THE TECHNOLOGY

The present technology relates generally to automatic reference countingin software programming.

BACKGROUND

Many electronic devices use software. The software is created bydevelopers and may employ references and/or objects. During theexecuting of the software it may become necessary for the reference todestroyed or undergo a cleanup process. The cleanup process allowshardware resources to be allocated efficiently during the executing ofthe software. Software is developed through the use of programminglanguages which are compiled into code that is usable by electronicdevices such as computer systems.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram of an environment for enabling automaticreference counting in accordance with embodiments of the presenttechnology.

FIG. 2 is flowchart for enabling automatic reference counting inaccordance with embodiments of the present technology.

FIG. 3 is flowchart for enabling automatic reference counting inaccordance with embodiments of the present technology.

The drawings referred to in this description of embodiments should beunderstood as not being drawn to scale except if specifically noted.

DESCRIPTION OF EMBODIMENTS

Reference will now be made in detail to embodiments of the presenttechnology, examples of which are illustrated in the accompanyingdrawings. While the technology will be described in conjunction withvarious embodiment(s), it will be understood that they are not intendedto limit the present technology to these embodiments. On the contrary,the present technology is intended to cover alternatives, modificationsand equivalents, which may be included within the spirit and scope ofthe various embodiments as defined by the appended claims.

Furthermore, in the following description of embodiments, numerousspecific details are set forth in order to provide a thoroughunderstanding of the present technology. However, the present technologymay be practiced without these specific details. In other instances,well known methods, procedures, user interface controls, and circuitshave not been described in detail as not to unnecessarily obscureaspects of the present embodiments.

Unless specifically stated otherwise as apparent from the followingdiscussions, it is appreciated that throughout the present descriptionof embodiments, discussions utilizing terms such as “searching,”“recognizing,” “replacing,” “executing,” “translating,” “converting,”“detecting,” “associating,” or the like, refer to the actions andprocesses of a computer system, or similar electronic computing device.The computer system or similar electronic computing device, such as asmart phone, or handheld mobile device, manipulates and transforms datarepresented as physical (electronic) quantities within the computersystem's registers and memories into other data similarly represented asphysical quantities within the computer system memories or registers orother such information storage, transmission, or display devices.Embodiments of the present technology are also well suited to the use ofother computer systems such as, for example, optical and mechanicalcomputers.

Overview of Automatic Reference Counting

Reference counting is a way of tracking bits of memory in the executionof a software source code where the memory is hardware in a computersystem or other device. The same piece or block of memory may bereferenced in several locations by the software source code. To makesure that memory stays valid, part of the data in the application willaccount for the references. When a bit of memory is not referred to, thesystem can collect it or release it and re-allocate it. An existingprogramming language may not have reference counting per se or may onlyhave parts that may be used by a developer for reference counting. Thepresent technology is able to modify existing source code withoutreference counting to a source code with an automatic reference countingimplementation. Automatic reference counting (ARC) is a technique forautomatically tracking the bits of memory. A compiler will generate anextra count to ensure count of the references is maintained. After areference is no longer valid then the code will remove it.

In one embodiment, automatic reference counting is a lightweight methodof garbage collection (GC) memory management techniques that enables thedeveloper to create software objects without requiring them to directlymanage the memory of the object's lifecycle, in particular itsdestruction and disposal. This feature is highly desirable on resourceconstrained mobile platforms where available memory is at a premium.Even in ARC and GC environments, there is a need sometimes fordeterministic way of initiating a “disposal” process. In otherenvironments this is accomplished by forcing the developer to “invent”their own mechanism such as in Java, or implement a specific codingpattern such as in .NET.

Embodiments of the present technology are for enabling automaticreference counting in a source code. The source code may be written inan existing programming language that may not initially supportautomatic reference counting or the source code may not be written withautomatic reference counting enabled. For example, the existingprogramming language may not have been developed with tools orstructures in place for automatic reference counting. A developer maydesire to add automatic reference counting to a source code but would berequired to create the tools or structures for automatic referencecounting for the source code from scratch. The present technologyenables automatic reference counting in the source code written in theexisting programming language without requiring the developer to createthe tools or structures to do so. In one embodiment, the enabling of theautomatic reference counting occurs hidden from the view of developer.

The process of enabling automatic reference counting in a source codemay be described as converting or translating a software source codefrom a non-ARC software source code to a software source code with ARCenabled. The process may also be described as managing the lifetime ofan object without the need to explicitly free the object where theobject is created and destroyed within an application flow.

In one embodiment, the present technology enables automatic referencecounting by searching a source code for a particular pattern. Theparticular pattern may be for a reference associating an object with aportion of memory. Once the particular pattern is recognized in thesource code, the particular pattern is then replaced with an automaticreference counting implementation. The source code is then translated orconverted and may then be executed with the automatic reference countingimplementation. Thus the present technology allows source code writtenin an existing programming language to be converted to an ARC-enabledsource code automatically where the source code and existing programminglanguage were created without automatic reference counting.

Enabling Automatic Reference Counting

Referring to the figures, exemplary embodiments of the technology willnow be described. The following description will focus on an embodimentof the present technology, which is implemented using a device with anoperating environment or platform such as an operating system. Thepresent technology, however, is not limited to any one particulardevice, operating system, environment, or platform. Instead, thoseskilled in the art will find that the system and methods of the presenttechnology may be advantageously embodied on a variety of differentplatforms, including Microsoft Windows, iOS, Android, Macintosh, Linux,Solaris, UNIX, FreeBSD, and the like. Therefore, the description of theexemplary embodiments that follows is for purposes of illustration andnot limitation.

FIG. 1 is a block diagram illustrating environment 100 which is anexample environment comprising computer system 101. It should beappreciated that computer system 101 may be a standard or customizedcomputer system and may be a desktop, laptop, tablet, handheld or othercomputer system. Computer system 101 may be employed by a developer foruse of the present technology. Computer system 101 comprises memory 108which is standard hardware memory. Bits of memory 108 may be referencedby source code 102 for use in the execution of source code 102. Sourcecode 102 refers to source code 102 for a software application. In oneembodiment, source code 102 comprises reference 105 which associates abit of memory 108 with object 106 of source code 102. In one embodiment,source code 102 is able to execute on more than one device than computersystem 101.

In one embodiment, source code 102 is developed or created using anexisting programming language. The existing programming language mayhave been developed or created such that it does not have the tools orstructures for automatic reference counting to be easily implemented.Thus a developer of source code 102 would need to program or create fromscratch the tools and structure necessary to enable an automaticreference counting implementation of source code 102. It should beappreciated that source code 102 may be existing source code 102 thatwas programmed or created without an automatic reference countingimplementation.

Source code 102 may have particular patterns of code in the actualsource code such as pattern 104. The pattern calls out a specificfunction and may be related to a reference such as reference 105. In oneembodiment, pattern 104 is reference 105 in source code 102. The presenttechnology is able to search source code 102 for pattern 104. Sourcecode 102 may contain multiple instances of a particular pattern.Compiler 109 is able to compile source code 102 into a machine usablecode. In one embodiment, compiler 109 is used to search for theparticular pattern. Once recognized the compiler, executing on computersystem 101, replaces pattern 104 with an implementation employing ARC110. ARC 110 is an automatic reference counting implementation. Onceimplemented, source code 102 with ARC 110 has been converted such thatautomatic reference counting is enabled for source code 102. Before theconversion, source code 102 may have been a non-ARC softwareapplication. A developer may issue a command for the conversion ofsource code 102 to a source code with an automatic reference countingimplementation. However, the actual conversion may be hidden from theview of the developer. Thus, the present technology may operate tocreate a source code with an automatic reference counting implementationwithout the developer being required to create or program the automaticreference counting. In one embodiment, the source code with an automaticreference counting implementation may be executed at computer system101. In one embodiment, the source code with an automatic referencecounting implementation is sent to device 112 to be executed. Forexample, device 112 may be a mobile device with a mobile platform suchas a smart phone. The present technology can move from one programminglanguage to another such as C++, Objective C, Delphi, and others.

There may be times during the execution of a software source code whereit is necessary to ensure that a block of memory is cleaned up meaningthat a reference may be pointing to a bit of memory when it no longerneed to. This prevents the bit of memory from being reference105-allocated. This reference needs to be identified and cleaned up ordestroyed. For example, a file system reference may need to be cleanedup. This may also be referred to as garbage collecting or disposing. Inanother example, in Delphi or C++ there is a destructor that destroysstate of object and allows it to become available. Automatic referencecounting can accomplish this cleanup task.

Some cleanup solutions employ a hidden flag to indicate whether adestructor should or should not destroy a reference. For example, a usermay invoke a disposeof feature, the destructor may be called withoutthat flag set, so all the destructors “run”, but no memory is freed. Theinstance is also marked as having been “disposed” so that any subsequentcall to disposeof is a no-op. All existing references to the instanceremain valid. The normal ARC process for controlling thedestruction/memory cleanup proceeds as normal and isn't disrupted.

In one embodiment, the reference is collected, not the object, and theautomatic reference counting removes the reference from being a livereference. In one embodiment, the present technology separates disposalfrom destruction of references. For example, a dispose of command ortechnique does not destroy the reference but instead marks an object asdisposed and executes as though the reference is destroyed. In thisembodiment, the memory still exists and the references are alive but areflagged as disposed. The memory may be in an indeterminate state, but isreturned to memory core and may be reallocated.

In one embodiment, there are live references that have not transitionedback to zero. The present technology may check if this live referencehas been disposed and may trigger a run time error. Thus the presenttechnology may be employed to highlight errors faster and be employed asa diagnostic tool. In one embodiment, the present technology is able totrack information such as the type and layout of memory and metadata,which is similar to Run Time Type Information RTTI or may be describedas reflection data. When an object or entity is released, it may stillhave references to other entities, the type information or metadatakeeps track of these references and automatic reference counting maythen operate to properly destroy or dispose of.

As references are transferred, the counters of references need to behandled which may be a problem if the counters are counting referencedifferently. Circular cycle or reference count which perpetuates a cyclethat may keep the reference alive. Automatic reference counting operatesto as a solution to this issue. In another embodiment, a “Weakreference” may be employed which keeps track of location where referencelives so that when other collect the memory, it knows location of otherweak reference. The weak reference may then be flagged for destructionor dispose of.

In one embodiment, the present technology employs method pointers topoint to a piece of code compiled in an application for conversion of asource to an automatic reference counting implementation. A methodpointer may point to an object such that a data structure carries areference to the memory that houses the data and also a reference to amethod that is to be called. In one embodiment, all method pointers aredesignated as weak and are tracked similar to a weak reference. Thus,the method pointer may be weak by implication.

In one embodiment, the present technology separates the concepts ofmemory deterministic and object determinism. For example, the object maynot be tied to the life of its memory in the present technology. In oneembodiment, the implementation of ARC allows for retaining the existing“create try finally free” (CTFF) pattern. For transitional classes wherethe lifetime can be tied to the function in which it lives, the CTFFpattern isn't strictly necessary. In some cases, however, a moredeterministic lifetime is necessary, so the CTFF pattern can be used.

The following describes different types of references. The differenttypes of references may have identifiers specific to a programminglanguage. For example, there may be identifiers specific to ObjectiveCor other programming languages. A strong identifier may be a default forany object instance reference. A weak identifier may be a type whichhandles the management of the weak reference. An autoreleasingidentifier may only apply to function parameters. By default allinstances passed as parameters are “autoreleasing”. On function entrythe reference count is incremented and on exit it is decremented. Tooverride this behavior, use the “const” modifier on the parameter. Thiswill have the same effect it has on string and interface parametertypes. In this case the callee relies on the caller to maintain thelifetime of the instance.

There are some instances where a reference counted object as a returntype will cause odd reference count problems. This is especially truefor TObject.InitInstance and TObject.NewInstance. These methods mustreturn a “raw” instance reference without the added refcount codegen.For these specific cases, the “unsafe” directive was resurrected fromthe Delphi for .NET compiler and re-purposed for an embodiment as a wayto indicated to the compiler that this return value must be treated as araw reference or pointer. In one embodiment, to mark a variable as aweak reference, the “unsafe” directive will shift to being an attribute[Unsafe].

In one embodiment, the risk of “Strong Reference Cycles” is very real.One solution is to introduce object reference variables that behavedifferently than a normal “strong” reference. A variable marked as weakwill not cause the referenced object to be retained, rather it willsimply be set to nil in the event that the variable is still in scopewhen the object is finally destroyed. This requires that the variable'slocation be actively tracked. As values are assigned to a weak variable,if it is currently holding a reference, that variable's location must beremoved from being tracked against that instance and the location isthen tracked against the new instance. When a weak reference is“finalized” it is set to nil and it's address is removed from thetracking table of the instance it is currently holding.

It should be appreciated that weak references can be set to nil at anypoint, even from another thread. Extreme care must be taken to ensurewhen accessing weak references. In one embodiment, a solution is thatobjects that cross threading boundaries are never referenced through aweak reference. As long as an object retains its thread affinity (i.e.is only accessed and managed from the thread on which it was created),race conditions and random crashes can be minimized.

In one embodiment, since a weak reference can be set to nil at anypoint, even as a result of same-thread processing, when using a weakreference, the weak reference is converted to a strong reference beforeusing it and clearing it immediately after use.

In some embodiments such as Delphi 2, where reference counted longstrings are employed, the compiler generates code and tables thatdescribe how to properly initialize and finalize variables and fields oftype ‘string.’ In subsequent embodiments, such as Delphi 3, this wasexpanded to include Variants, Interfaces and WideStrings. EventuallyDynamic Arrays were also added and most recently, UnicodeString.Finally, as this document points out, class instance references are nowalso included among those types previously referenced.

The tables used by the RTL to properly finalize a class, record, array,local variable, etc. are simply an array of records containing twofields. The first is a reference to the type information (RTTI) for thetype of the field, and the second field is the offset in the containingstructure for where the field to be finalized is located. Given the baseaddress of the structure, which can be on the stack or heap, the memoryaddress of the field can be calculated, and given the type informationreference, the RTL knows how to specifically finalize that field.

In one embodiment, with the addition of being able to apply the weakattribute to a field, a field of a given type must be copied and/orfinalized differently from fields that are strong references. Thispresented a problem since the aforementioned table only contains anoffset and type reference. A strong field reference or weak fieldreference to the same type would generate the exact same type referenceand the since they're different fields the offsets would obviously bedifferent. However the RTL would be unable to distinguish the differencebetween the fields by merely looking at the corresponding entry in thetable.

In one embodiment, in order to minimize the overall impact on thecompiler and RTL, the entries in the finalization table remained thesame. The difference is rather than interleaving strong and weakreference fields, they are segregated into different regions in thearray with a “sentinel” marking the point between them. The RTLprocesses the finalization table linearly as an array of typeinfo/offsetpairs. The compiler generates all the strong references into the firstpart of the array. If the structure contains any weak reference fields,a “sentinel” record consisting of two nil values (nil typeinfo and 0offset field) will indicate that all entries following this point willbe weak references. The finalization structure header contains a fieldindicating the number of items in the finalization array. If a structureincludes any weak references, this count will include the sentinel entryas part of the total count.

In one embodiment, a programming language that can develop a source codewith an automatic reference counting implementation, it is feasible toallow operators on classes. This would be different from prior solutionswhere operators are only allowed on records.

In an embodiment using a Delphi language solution, “Boxing” is the actof taking a “value-type” and wrapping it up into a class and moving itto the heap as a reference type. “Unboxing” does the opposite byextracting the value from the object instance. This would allow for theability to safely cast an integer into a TObject. In one embodiment,instead of taking the *value* of the integer and reinterpreting the“bits” of an integer as a class reference, an actual TObject “wrapper”instance would be created and the value gets copied to the instance. Theact of casting a TObject back into an integer, would reverse the processby safely checking whether the TObject instance is an Integer wrapperand then copy the value from it. The “box” (or wrapper) would be cleanedup automatically as the references are dropped.

Operations

FIG. 2 is a flowchart illustrating process 200 for enabling automaticreference counting, in accordance with one embodiment of the presentinvention. In one embodiment, process 200 is carried out, at least inpart, by processors and electrical user interface controls under thecontrol of computer readable and computer executable instructions storedon a computer-usable storage medium. The computer readable and computerexecutable instructions reside, for example, in data storage featuressuch as computer usable volatile and non-volatile memory and arenon-transitory. However, the non-transitory computer readable andcomputer executable instructions may reside in any type ofcomputer-usable storage medium. In one embodiment, process 200 isperformed by devices and modules in FIG. 1.

At 202, a source code is searched for a particular pattern via acompiler associated with a computer system, wherein the source code iswritten in an existing language and wherein the particular pattern isfor a reference associating an object with a portion of memory. Forexample, the computer system may be computer system 101 of FIG. 1 withsource code 102 and compiler 109 searching for pattern 104 where pattern104 is reference 105 associating object 106 to a portion of memory 108.

In one embodiment, the source code is initially a non-automaticreference counting source code. In one embodiment, the source code istranslated or converted from the non-automatic reference counting sourcecode to a software source code with automatic reference countingenabled. In one embodiment, the existing language was developed withoutautomatic reference counting as a function of the existing language.

At 204, the particular pattern is recognized at the computer system.

At 206, the particular pattern is replaced with an automatic referencecounting implementation at the computer system. This may be accomplishedwith ARC 110. In one embodiment, the automatic reference countingperforms a cleanup of a reference automatically. In one embodiment, theautomatic reference counting implementation is accomplished such thatthe source code can execute an object destructor on demand.

At 208, the source code with the automatic reference countingimplementation is executed. The execution may occur at computer system101 and/or device 112 which may be described as a second computersystem.

In one embodiment, process 200 is hidden from the view of a developer.In one embodiment, process 200 may be implemented on a variety ofdifferent programming language such as C++, Objective C, Delphi, andothers.

FIG. 3 is a flowchart illustrating process 300 for enabling automaticreference counting, in accordance with one embodiment of the presentinvention. In one embodiment, process 300 is carried out, at least inpart, by processors and electrical user interface controls under thecontrol of computer readable and computer executable instructions storedon a computer-usable storage medium. The computer readable and computerexecutable instructions reside, for example, in data storage featuressuch as computer usable volatile and non-volatile memory and arenon-transitory. However, the non-transitory computer readable andcomputer executable instructions may reside in any type ofcomputer-usable storage medium. In one embodiment, process 300 isperformed by devices and modules in FIG. 1.

At 302, a source code is converted, at a computer system, written in anexisting language such that automatic reference counting is enabled fromthe source code. For example, the computer system may be computer system101 of FIG. 1 with source code 102 and compiler 109 searching forpattern 104 where pattern 104 is reference 105 associating object 106 toa portion of memory 108.

In one embodiment, the source code is initially a non-automaticreference counting source code. In one embodiment, the source code istranslated or converted from the non-automatic reference counting sourcecode to a software source code with automatic reference countingenabled. In one embodiment, the existing language was developed withoutautomatic reference counting as a function of the existing language.

At 304, the source code is executed with the automatic referencecounting implementation.

At 306, an object destructor is run as part of the source code with theautomatic reference counting on demand during the executing, wherein theobject destructor is for use in an explicit disposal process of areference associated with the source code. In one embodiment, theautomatic reference counting performs a cleanup of a referenceautomatically. In one embodiment, the automatic reference countingimplementation is accomplished such that the source code can execute anobject destructor on demand.

In one embodiment, process 300 is hidden from the view of a developer.In one embodiment, process 300 may be implemented on a variety ofdifferent programming language such as C++, Objective C, Delphi, andothers.

While the technology is described in some detail with specific referenceto embodiments and alternatives, there is no intent to limit thetechnology to a particular embodiment or specific alternatives. Forinstance, those skilled in the art will appreciate that modificationsmay be made to embodiments without departing from the teachings of thepresent technology.

Example Computer System Environment

The present technology may be carried out, associated with or otherwisepracticed with a computer system. Portions of the present technology arecomposed of computer-readable and computer-executable instructions thatreside, for example, in computer-usable media of a computer system orother user device such as computer system 101 and/or device 112 ofFIG. 1. Described below is an example computer system or components thatmay be used for or in conjunction with aspects of the present technologysuch as the ability to run or create a three dimensional interface.

It is appreciated that that the present technology can operate on orwithin a number of different computer systems including general purposenetworked computer systems, embedded computer systems, a personalcomputer such as a desktop computer, a laptop, a notebook, an electronichandheld device, a personal digital assistant, a smart phone, a tabletcomputer, a net book, user devices, and the like. The computer system iswell adapted to having peripheral computer readable media such as, forexample, a floppy disk, a compact disc, flash memory and the likecoupled thereto.

The computer system includes an address/data bus for communicatinginformation, and a processor coupled to bus for processing informationand instructions. The computer system is also well suited to amulti-processor or single processor environment and also includes datastorage features such as a computer usable volatile memory, e.g. randomaccess memory (RAM), coupled to bus for storing information andinstructions for processor(s).

The computer system may also include computer usable non-volatilememory, e.g. read only memory (ROM), as well as input devices such as analpha-numeric input device, a mouse, or other commonly used inputdevices. The computer system may also include a display such as liquidcrystal device, cathode ray tube, plasma display, and other outputcomponents such as a printer or other common output devices.

The computer system may also include one or more signal generating andreceiving device(s) coupled with a bus for enabling the system tointerface with other electronic devices and computer systems. Signalgenerating and receiving device(s) of the present embodiment may includewired serial adaptors, modems, and network adaptors, wireless modems,and wireless network adaptors, and other such communication technology.The signal generating and receiving device(s) may work in conjunctionwith one or more communication interface(s) for coupling information toand/or from the computer system. A communication interface may include aserial port, parallel port, Universal Serial Bus (USB), Ethernet port,antenna, or other input/output interface. A communication interface mayphysically, electrically, optically, or wirelessly (e.g. via radiofrequency) couple the computer system with another device, such as acellular telephone, radio, a handheld device, a smart phone, or computersystem.

Although the subject matter is described in a language specific tostructural features and/or methodological acts, it is to be understoodthat the subject matter defined in the appended claims is notnecessarily limited to the specific features or acts described above.Rather, the specific features and acts described above are disclosed asexample forms of implementing the claims.

What is claimed:
 1. A method for enabling automatic reference counting,said method comprising: searching a source code for a particular patternvia a compiler associated with a computer system, wherein said sourcecode is written in an existing language and wherein said particularpattern is for a reference associating an object with a portion ofmemory; recognizing a location of said particular pattern in said sourcecode at said computer system; replacing said particular pattern with anautomatic reference counting implementation by said compiler at saidcomputer system without requiring a developer to develop structures forsaid automatic reference counting specific to said existing language,such that said source code executes an object destructor on demandirrespective of whether there are live references to said object,wherein said object destructor marks said object as disposed withoutfreeing said portion of memory associated with said object and withoutimpacting validity of said reference to said object; and executing saidsource code with said automatic reference counting implementation,wherein said automatic reference counting collects a reference andremoves said reference from being a live reference, and wherein markingof said object as disposed by said object destructor is executed ondemand based on said source code irrespective of whether there are livereferences to said object and without impacting validity of saidreference to said object.
 2. The method as recited in claim 1 whereinsaid existing language was developed without automatic referencecounting as a function of the existing language.
 3. The method asrecited in claim 1 wherein said executing occurs at said computersystem.
 4. The method as recited in claim 1 wherein said source codewith said automatic reference counting implementation is sent to secondcomputer system such that said executing occurs at said second computersystem.
 5. The method as recited in claim 1 wherein said automaticreference counting performs a cleanup of a reference automatically. 6.The method as recited in claim 1 wherein said searching, recognizing,replacing, and executing are performed for more than one type ofprogramming language.
 7. The method as recited in claim 1 wherein saidreplacing said particular pattern with said automatic reference countingimplementation is hidden from view.
 8. The method as recited in claim 1wherein said source code is initially a non-automatic reference countingsource code.
 9. The method as recited in claim 8 wherein said replacingsaid particular pattern allows said compiler to interpret saidnon-automatic reference counting source code to a software source codewith automatic reference counting enabled.
 10. The method as recited inclaim 1 wherein said reference is a weak reference.
 11. The method asrecited in claim 10, further comprising: responsive to collecting theportion of memory associated with said objecting, disposing of said weakreference.
 12. A non-transitory computer-usable storage medium havinginstructions embodied therein that when executed cause a computer systemto perform a method for enabling automatic reference counting, saidmethod comprising: searching a source code for a particular pattern viaa compiler associated with a computer system, wherein said source codeis written in an existing language and wherein said particular patternis for a reference associating an object with a portion of memory;recognizing a location of said particular pattern in said source code atsaid computer system; replacing said particular pattern with anautomatic reference counting implementation by said compiler at saidcomputer system without requiring a developer to develop structures forsaid automatic reference counting specific to said existing language,such that said source code executes an object destructor on demandirrespective of whether there are live references to said object,wherein said object destructor marks said object as disposed withoutfreeing said portion of memory associated with said object and withoutimpacting validity of said reference to said object; and executing saidsource code with said automatic reference counting implementation,wherein said automatic reference counting collects a reference andremoves said reference from being a live reference, and wherein markingof said object as disposed by said object destructor is executed ondemand based on said source code irrespective of whether there are livereferences to said object and without impacting validity of saidreference to said object.
 13. The non-transitory computer-usable storagemedium as recited in claim 12 wherein said source code is initially anon-automatic reference counting source code.
 14. The non-transitorycomputer-usable storage medium as recited in claim 12 wherein saidexisting language was developed without automatic reference counting asa function of the existing language.
 15. A method for enabling automaticreference counting, said method comprising: converting a source code, bya compiler of a computer system, written in an existing language suchthat automatic reference counting is enabled from said source codewithout requiring a developer to develop structures for said automaticreference counting specific to said existing language, such that saidsource code executes an object destructor on demand irrespective ofwhether there are live references to an object, wherein said objectdestructor marks said object as disposed without freeing a portion ofmemory associated with said object and without impacting validity of areference to said object, said converting a source code comprising:replacing a particular pattern of said source code with an automaticreference counting implementation by said compiler at said computersystem; executing said source code with said automatic referencecounting implementation; and running an object destructor as part ofsaid source code with said automatic reference counting on demand duringsaid executing, wherein said object destructor is for use in an explicitdisposal process of a reference associated with said source code,wherein said object destructor collects a reference and removes saidreference from being a live reference, and wherein marking of saidobject as disposed by said object destructor is executed on demand basedon said source code irrespective of whether there are live references tosaid object and without impacting validity of said reference to saidobject.
 16. The method as recited in claim 15 wherein said source codeis initially a non-automatic reference counting source code.
 17. Themethod as recited in claim 15 wherein said existing language wasdeveloped without automatic reference counting as a function of theexisting language.
 18. The method as recited in claim 15 wherein saidexplicit disposal process only needs to be run once for said referenceassociated with said source code.
 19. The method as recited in claim 15wherein said converting said source code are performed for more than onetype of programing language.
 20. The method as recited in claim 15wherein said converting said source code is hidden from view.